package com.huoyun.car.action;

import java.util.List;

import com.huoyun.base.action.BaseAction;
import com.huoyun.car.model.CarPubInfoModel;
import com.huoyun.car.service.CarPubInfoService;
import com.huoyun.car.service.CarRouteService;

public class ManageMyPublishedCars extends BaseAction{
	private static final long serialVersionUID = 1L;
	
	/**
	 * 管理"车源信息"的service
	 */
	private CarPubInfoService carPubInfoService;
	
	/**
	 * "详细车源信息"列表
	 */
	private List<CarPubInfoModel> myCarPubInfoItemList;
	
	/**
	 * 管理"起始地、到达地信息"的service
	 */
	private CarRouteService carRouteService;

	/**
	 * 获取当前用户发布的所有"车源信息"
	 * @return SUCCESS
	 */
	public String showMyPublishedCars() {
		
		this.myCarPubInfoItemList = carPubInfoService.getCarPubInfoItemListByUserId(getLoginUser().getId());
		
		return SUCCESS;
	}
	
	/**
	 * 删除指定的"车源信息"
	 * @return SUCCESS
	 */
	public String deleteMyPublishedCar() {
		
		int carPubInfoId = Integer.parseInt(getRequest().getParameter("carPubInfoId"));
		this.carPubInfoService.deleteCarPubInfoById(carPubInfoId);
		this.carRouteService.deleteCarRoutesByCarPubInfoId(carPubInfoId);
		
		return SUCCESS;
	}

	public CarPubInfoService getCarPubInfoService() {
		return carPubInfoService;
	}

	public void setCarPubInfoService(CarPubInfoService carPubInfoService) {
		this.carPubInfoService = carPubInfoService;
	}

	public List<CarPubInfoModel> getMyCarPubInfoItemList() {
		return myCarPubInfoItemList;
	}

	public void setMyCarPubInfoItemList(List<CarPubInfoModel> myCarPubInfoItemList) {
		this.myCarPubInfoItemList = myCarPubInfoItemList;
	}

	public CarRouteService getCarRouteService() {
		return carRouteService;
	}

	public void setCarRouteService(CarRouteService carRouteService) {
		this.carRouteService = carRouteService;
	}

}
